<?php
/**
 * Database abstraction interface
 * 
 * @author Patrick J. Mizer <patrick.mizer@gmail.com>
 * @author Alexander Schearer <aas11@duke.edu>
 * 
 * @package junction.db.common
 */
interface Db_Common_Service
{	
	/**
	 * Perform a query which effects the database
	 *
	 * @throws Db_Common_SqlException
	 * @param String $query
	 * @return boolean
	 */
	public function save($query);
	
	/**
	 * Perform a query which returns a result set
	 *
	 * @throws Db_Common_SqlException
	 * @param String $query
	 * @return Db_Common_ResultSet
	 */
	public function select($query);
	
	/**
	 * Construct a prepared query which can be re-used with different values
	 * 
	 * <p>The compilation requires that the query use binding instead of positional
	 * flags.
	 * 
	 * @return Db_Common_PreparedStatement
	 */
	public function prepare($query);
	
	/**
	 * Returns the number of rows affected by the previous query
	 *
	 * @return int
	 */
	public function affectedRows();
	
	/**
	 * Returns the key for the previously inserted row
	 *
	 * @return int
	 */
	public function lastInsertId();
	
	/**
	 * Enter into transactional mode
	 *
	 * @return boolean
	 */
	public function startTransaction();
	
	/**
	 * Exit transactional mode committing any queries
	 *
	 * @return boolean
	 */
	public function stopTransaction();
}
?>